package com.yuma.string;

public class StringDemo3 {
    public static void main(String[] args) {
        String s = new String("1");
        s.intern();
        String s2 = "1";
        System.out.println(s == s2);//jdk7/8:  false

        String s3 = new String("1") + new String("1");
        s3.intern();  // "11" s3指向了常量池中的11
        String s4 = "11";  // 常量池
        System.out.println(s3 == s4);//jdk7/8:  true
    }
}
